package com.letoken.platform.repo.admin.manager;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.letoken.platform.repo.admin.dao.AdminUserMapper;
import com.letoken.platform.repo.admin.dao.AdminUserRoleMapper;
import com.letoken.platform.repo.admin.po.AdminUser;
import com.letoken.platform.repo.admin.res.user.AdminUserInfoRes;
import com.letoken.platform.repo.app.redis.AppLoginTokenRedis;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wyl
 * @date 2022/12/26 18:59
 * @Version 1.0
 */
@Log4j2
@Repository
public class AdminUserManager {

    @Autowired
    private AdminUserMapper adminUserMapper;

    @Autowired
    private AdminUserRoleMapper adminUserRoleMapper;

    public List<AdminUser> queryUserListByRoleId(Integer adminRoleId) {
        List<Integer> userIdList = adminUserRoleMapper.queryAdminIdListByRoleId(adminRoleId);
        if(userIdList.size()==0){
            return new ArrayList<AdminUser>();
        }
        LambdaQueryWrapper<AdminUser> queryWrapper = Wrappers.lambdaQuery();
        queryWrapper.in(AdminUser::getAdminUserId, userIdList);
        return adminUserMapper.selectList(queryWrapper);
    }


//    public AdminUserInfoRes queryMe(){
//        AdminUserInfoRes adminUserInfoRes = AppLoginTokenRedis.me().getAdminUserInfoRes();
//        adminUserMapper
//    }
}
